package com.cskaoyan.service;

import com.cskaoyan.bean.Brand;
import com.cskaoyan.bean.vo.BrandVO;
import com.cskaoyan.mapper.BrandMapper;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class BrandServiceImpl implements BrandService {

    @Autowired
    BrandMapper brandMapper;

    @Override
    public Map<String, Object> ListBrand(Integer page, Integer size) {

        PageHelper.startPage(page,size);
        List<BrandVO> brandVOList = brandMapper.selectVOList();
        int total = brandVOList.size();
        HashMap<String, Object> map = new HashMap<>();
        map.put("total",total);
        map.put("brandList",brandVOList);
        return map;
    }

    @Override
    public Brand brandDetail(Integer id) {
        Brand brand = brandMapper.selectByPrimaryKey(id);
        return brand;
    }

}
